<%@page pageEncoding = "utf-8" contentType = "text/html;charset=utf-8"%>

<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt"%>

<h2><fmt:message key = "form.addRequest"/></h2>

<div class = "messages"><jsp:include page = "/messages.jsp"/></div>

<form action = "operatorui" method = "post" name = "requestAddForm">
   <table class = "form">
      <tr>
         <td class = "label"><fmt:message key = "request.regNumber"/></td>
         <td>
            <input type="text" name="regNumber" maxlength="50" value='<c:out value = "${requestBean.regNumber}"/>'/>
         </td>
      </tr>
         
      <tr>
         <td class = "label"><fmt:message key = "request.organization"/><span class="star">*</span></td>
         <td>
            <select id="organizationsList" name="organization_id">              
              <!-- <option value="0"><fmt:message key = "request.selectOrganization"/></option> -->
              <c:forEach var = "organization" items = "${organizationsList}">
                <option value="${organization.id}" ${organization.id == requestBean.organizationId ? "selected" : ""}>
                   <c:out value="${organization.shortTitle}"/>
                </option>
              </c:forEach>
            </select>            
            <span class="error"><c:out value="${error.organization}"/></span>
         </td>
      </tr>
      
      
      <tr>
         <td class = "label"><fmt:message key = "request.department"/><span class="star">*</span></td>
         <td>
            <select id="departmentsList" name="department_id">
              <!-- <option value="0"><fmt:message key = "request.selectDepartment"/></option> -->
              <c:forEach var = "department" items = "${departmentsList}">
                <option value="${department.id}" ${department.id == requestBean.departmentId ? "selected" : ""}>
                   <c:out value="${department.name}"/>
                </option>
              </c:forEach>
            </select>            
            <span class="error"><c:out value="${error.department}"/></span>
         </td>
      </tr>
            
      <tr>
         <td class = "label"><fmt:message key = "request.client"/><span class="star">*</span></td>
         <td>
            <select id="clientsList" name="client_id">
            	<option value="0"><fmt:message key = "request.selectClient"/></option>
              <c:forEach var = "client" items = "${clientsList}">
                <option value="${client.id}" ${client.id == requestBean.clientId ? "selected" : ""}>
                   <c:out value="${client.lastName}"/>&nbsp;<c:out value="${client.firstName}"/>
                </option>
              </c:forEach>
            </select>            
            <span class="error"><c:out value="${error.client}"/></span>
         </td>
      </tr>
      
      <tr>
         <td class = "label"><fmt:message key = "request.room"/></td>
         <td>
            <input type="text" name="room" maxlength="50" value='<c:out value = "${requestBean.room}"/>'/>
         </td>
      </tr>
          
      <tr>
         <td class = "label"><fmt:message key = "request.text"/><span class="star">*</span></td>
         <td>
            <textarea name = "dispatcherText" rows="10" cols="50"><c:out value = "${requestBean.dispatcherText}"/></textarea>
            <span class="error"><c:out value="${error.dispatcherText}"/></span>
         </td>
      </tr>

      <tr>
         <td class = "label"><fmt:message key = "request.group"/></td>
         <td>
            <select name="group_id">
               <c:forEach var = "group" items = "${groupsList}">
                  <option value="${group.id}" ${group.id == requestBean.groupId ? "selected" : ""}>
                  	<c:out value = "${group.name}"/>
                  </option>
               </c:forEach>
            </select>              
            <span class="error"><c:out value="${error.group}"/></span>
         </td>
      </tr>               
      
      <tr>
         <td class = "label"><fmt:message key = "request.requestType"/></td>
         <td>
            <select name="requesttype_id">              
              <c:forEach var = "requestType" items = "${requestTypesList}">
                <option value="${requestType.id}" ${requestType.id == requestBean.requestTypeId ? "selected" : ""}>
                   <c:out value="${requestType.type}"/>
                </option>
              </c:forEach>
            </select>            
            <span class="error"><c:out value="${error.requestType}"/></span>
         </td>
      </tr>
      
      <tr>
         <td class = "label"><fmt:message key = "request.comment"/></td>
         <td>
            <textarea name = "comment" rows="10" cols="50"><c:out value = "${requestBean.comment}"/></textarea>            
         </td>
      </tr>
</table>

<input name = "_action" type = "hidden" value = "addRequest">

<p><span class="small">Обязательные для заполнения поля отмечены </span> <span class="star">*</span></p>     

<p>
  <input type="submit" value = '<fmt:message key = "Command.RequestCommit"/>' onclick="return confirm('Вы действительно хотите принять заявку?')">
  или  
  <a href = 'javascript:doAction("dumb");'>
    <fmt:message key = "Command.cancel"/>
  </a>
</p>

</form>